package com.mall.service.impl;


import com.mall.beans.Address;
import com.mall.mapper.AddressMapper;
import com.mall.service.AddressService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 收货地址表(Address)表服务实现类
 *
 * @author 蔡文智
 * @since 2020-12-29 09:53:44
 */
@Service("addressService")
public class AddressServiceImpl implements AddressService {
    @Resource
    private AddressMapper addressMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Address queryById(Integer id) {
        return this.addressMapper.queryById(id);
    }

    @Override
    public int add(Address address) {
        return this.addressMapper.add(address);
    }

    @Override
    public int updateAdd(Address address) {
        return this.addressMapper.updateAdd(address);
    }

    @Override
    public int deleteAdd(int id) {
        return this.addressMapper.deleteAdd(id);
    }

    @Override
    public List<Address> all() {
        return this.addressMapper.all();
    }

    @Override
    public Address test(Integer userId){
        return this.addressMapper.test(userId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
//    @Override
//    public List<Address> queryAllByLimit(int offset, int limit) {
//        return this.addressMapper.queryAllByLimit(offset, limit);
//    }

    /**
     * 新增数据
     *
     * @param address 实例对象
     * @return 实例对象
     */
//    @Override
//    public Address insert(Address address) {
//        this.addressMapper.insert(address);
//        return address;
//    }

    /**
     * 修改数据
     *
     * @param address 实例对象
     * @return 实例对象
     */
//    @Override
//    public Address update(Address address) {
//        this.addressMapper.update(address);
//        return this.queryById(address.getId());
//    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
//    @Override
//    public boolean deleteById(Integer id) {
//        return this.addressMapper.deleteById(id) > 0;
//    }
}